<?php

namespace App\Http\Controllers\CRM\MiniAPP;

use App\Helper\ApiResponseHelper;
use App\Http\Controllers\Controller;
use App\Http\Requests\CRM\MiniAPP\DuelLevelRequest;
use App\Http\Resources\CRM\MiniAPP\DuelLevelResource;
use App\Models\DuelLevel;
use Illuminate\Http\Request;

class DuelLevelController extends Controller
{
    public function getList()
    {
        $levels = DuelLevel::latest()->get();

        return DuelLevelResource::collection($levels);
    }

    public function create(DuelLevelRequest $request)
    {
        $level = DuelLevel::create($request->only(['name']));

        return new DuelLevelResource($level);
    }

    public function remove(DuelLevel $level)
    {
        $level->delete();

        return ApiResponseHelper::json([]);
    }
}
